package org.dg.dgimg;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import org.apache.ibatis.annotations.Mapper;

import java.nio.file.Paths;
import java.util.Collections;

public class Generator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/dgimg?userUnicode=true&characterEncoding=utf-8", "root", "123456")
                .globalConfig(builder -> builder
                        .author("DG")
                        .outputDir(Paths.get(System.getProperty("user.dir")) + "/src/main/java")
                        .commentDate("yyyy-MM-dd")

                )
                .packageConfig(builder -> builder
                        .parent("org.dg.dgimg")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .pathInfo(Collections.singletonMap(OutputFile.xml, "")) // 禁用生成 XML 文件
                )
                .strategyConfig(builder -> builder
                        .addInclude("user")
                        .entityBuilder()
                        .enableLombok() // 启用 Lombok 注解
                        .disableSerialVersionUID() // 可选：禁用生成 serialVersionUID
                        .mapperBuilder()
                        .mapperAnnotation(Mapper.class) // 指定 Mapper 注解，这里假设是 @Mapper
                        .build()
                )
                .execute();
    }
}
